home *** CD-ROM | disk | FTP | other *** search
/ QuickTime 2.0 Developer Kit / QuickTime 2.0 Developer Kit.iso / mac / MAC / Programming Stuff / Sample Code / Movie Toolbox / Inside Mac Movie Toolbox Code / mtb3.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-12-05  |  2.1 KB  |  100 lines  |  [TEXT/MPS ]

  1. /*
  2.   File:            mtb3.c
  3.   Contains:        Main Function
  4.   Written by:    DTS and QT Engineering
  5.   Copyright:    © 1992-1994 by Apple Computer, Inc., all rights reserved.
  6.   Change History (most recent first):
  7.   <1>         12/4/94    khs        changed the format of the file to the new look and feel
  8.   To Do:
  9. */
  10.  
  11.  
  12. // INCLUDES
  13. #include "mtb.h"
  14.  
  15.  
  16. // MAIN
  17. void main(void)
  18. {
  19.     MovieController aController;
  20.     WindowPtr aWindow;
  21.     Rect aRect;
  22.     Movie aMovie;
  23.     Boolean done = false;
  24.     OSErr err;
  25.     EventRecord theEvent;
  26.     WindowPtr whichWindow;
  27.     short part;
  28.  
  29.     InitGraf(&qd.thePort);
  30.     InitFonts();
  31.     InitWindows();
  32.     InitMenus();
  33.     TEInit();
  34.     InitDialogs(nil);
  35.     MaxApplZone();
  36.  
  37.     if (!IsQuickTimeInstalled())
  38.     {
  39.         CheckError(-1, "\pPlease install QuickTime and try again.");
  40.     }
  41.  
  42.     err = EnterMovies();
  43.     if (err)
  44.         return;
  45.  
  46.     SetRect(&aRect, 100, 100, 200, 200);
  47.     aWindow = NewCWindow(nil, &aRect, "\pMovie", false, noGrowDocProc, (WindowPtr) - 1, true, 0);
  48.     SetPort(aWindow);
  49.     aMovie = GetMovie();
  50.     if (aMovie == nil)
  51.         return;
  52.  
  53.     SetRect(&aRect, 0, 0, 100, 100);
  54.     aController = NewMovieController(aMovie, &aRect, mcTopLeftMovie);
  55.     if (aController == nil)
  56.         return;
  57.  
  58.     err = MCGetControllerBoundsRect(aController, &aRect);
  59.     SizeWindow(aWindow, aRect.right, aRect.bottom, true);
  60.     ShowWindow(aWindow);
  61.     err = MCDoAction(aController, mcActionSetKeysEnabled, (Ptr)true);
  62.  
  63.     while (!done)
  64.     {
  65.         WaitNextEvent(everyEvent, &theEvent, 0, nil);
  66.         if (!MCIsPlayerEvent(aController, &theEvent))
  67.         {
  68.             switch (theEvent.what)
  69.             {
  70.                 case updateEvt:
  71.                     whichWindow = (WindowPtr)theEvent.message;
  72.                     BeginUpdate(whichWindow);
  73.                     EraseRect(&whichWindow->portRect);
  74.                     EndUpdate(whichWindow);
  75.                     break;
  76.                 case mouseDown:
  77.                     part = FindWindow(theEvent.where, &whichWindow);
  78.                     if (whichWindow == aWindow)
  79.                     {
  80.                         switch (part)
  81.                         {
  82.                             case inGoAway:
  83.                                 done = TrackGoAway(whichWindow, theEvent.where);
  84.                                 break;
  85.  
  86.                             case inDrag:
  87.                                 DragWindow(whichWindow, theEvent.where, &qd.screenBits.bounds);
  88.                                 break;
  89.                         }
  90.                     }
  91.             }
  92.         }
  93.     }
  94.     DisposeMovieController(aController);
  95.     DisposeMovie(aMovie);
  96.     DisposeWindow(aWindow);
  97. }
  98.  
  99.  
  100.